package com.haoze.nurseapp.dao;

import com.haoze.common.mapper.MyMapper;
import com.haoze.nurseapp.dto.*;
import com.haoze.nurseapp.dto.Assessment.CirculationTemplateDTO;
import com.haoze.nurseapp.dto.Assessment.CommonTaskCirculationDTO;
import com.haoze.nurseapp.model.*;
import feign.Param;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

public interface CirculationLogMapper extends MyMapper<CirculationLogEntity> {

    List<CirculationLogEntity> findCirculationLogByRowId(@Param("rowId") String rowId);

    int selectIsOrderActive(@Param("inpatNum") String inpatNum);

    CirculationLogEntity selectNewLogByInpatNum(@Param("inpatNum") String inpatNum,@Param("circulationLogId") String circulationLogId);

    CirculationLogEntity selectNewLogOutHospByInpatNum(@Param("inpatNum") String inpatNum);

    void finishLogStatus(@Param("inpatNum") String inpatNum,@Param("inTime") String inTime, @Param("operateType") String operateType, @Param("modelType") String modelType);

    Map<String,String> getRotating(@Param("inpatNum") String inpatNum);

    String getDiagName(@Param("inpatNum") String inpatNum);

    void updateLogStatus(@Param("inpatNum") String inpatNum,@Param("inTime") String inTime);

    void updateCancel(@Param("logId") String logId,@Param("operator") String operator);

    void updateLogStatusById(@Param("logId") String logId,@Param("inTime") String inTime,@Param("outTime") String outTime,@Param("state") String state,@Param("operator") String operator);
    void updateLogStatusById2(@Param("logId") String logId,@Param("inTime") String inTime,@Param("outTime") String outTime,@Param("state") String state,
                              @Param("operator") String operator,@Param("inWardDeptId") String inWardDeptId,@Param("inDeptId") String inDeptId);

    void updatePatient(@Param("inpatNum") String inpatNum, @Param("bedNo") String bedNo,@Param("deptId") String deptId,@Param("inWardId") String inWardId,@Param("doctorPersonId") String doctorPersonId,@Param("nurseId") String nurseId);
    void updatePatientOut(@Param("inpatNum") String inpatNum, @Param("bedNo") String bedNo,@Param("deptId") String deptId,@Param("inWardId") String inWardId);
    void updatePatientOut2(@Param("inpatNum") String inpatNum, @Param("bedNo") String bedNo,@Param("deptId") String deptId,@Param("inWardId") String inWardId);

    List<Map<String,String>> getRotatingList(@Param("inpatNum") String inpatNum,@Param("status") String status,@Param("operateType") String operateType,
                                             @Param("modelType") String modelType,@Param("inpatorderdataId") String inpatorderdataId,
                                             @Param("circulationlLogId") String circulationlLogId);

    List<Map<String,String>> getPatientList(@Param("circulationType") List<String> circulationType,
                                            @Param("status") String status,@Param("endDate") String endDate,@Param("startDate") String startDate,
                                            @Param("keyWords") String keyWords,@Param("inWardDeptId") String inWardDeptId,@Param("outWardDeptId") String outWardDeptId,@Param("type") String type,
                                            @Param("wardDeptId") String wardDeptId,
                                            @Param("deptArea") String deptArea);

    List<Map<String,String>> getPatientListByInpatNum(@Param("endDate") String endDate,@Param("startDate") String startDate,
                                                      @Param("type") String type,
                                                      @Param("outWardDeptId") String wardDeptId,
                                                      @Param("deptArea") String deptArea,
                                                      @Param("inpatNum") String inpatNum);


    List<String> getModelTypes(@Param("circulationType") List<String> circulationType,
                                            @Param("status") String status,@Param("endDate") String endDate,@Param("startDate") String startDate,
                                            @Param("keyWords") String keyWords,@Param("inWardDeptId") String inWardDeptId,@Param("outWardDeptId") String outWardDeptId,
                                            @Param("wardDeptId") String wardDeptId);

    List<String> getModelTypesInInpatNum(@Param("circulationType") List<String> circulationType,@Param("endDate") String endDate,@Param("startDate") String startDate,
                                         @Param("wardDeptId") String wardDeptId,@Param("inpatNum") String inpatNum);


    CirculationLogEntity getWaitOutHosp(@Param("inpatNum") String inpatNum,@Param("circulationLogId") String circulationLogId);

    int updateWaitOutHosp(@Param("circulationLogId") String circulationLogId,@Param("operator") String operator);
    int updateCancleFlagOutHosp(@Param("circulationLogId") String circulationLogId,@Param("operator") String operator);
    int updateCancleFlag(@Param("circulationLogIds") List<String> circulationLogIds,@Param("operator") String operator);
    List<Map<String, String>> queryDeptByWardDeptId(@Param("contentId") String contentId,@Param("id") String id,@Param("keyWords") String keyWords);

    List<Map<String, String>> queryWardDeptByDeptId(@Param("contentId") String contentId,@Param("id") String id,@Param("keyWords") String keyWords);

    CirculationLogEntity getPatientInfo(@Param("inpatNum") String inpatNum,@Param("modelType") String modelType,@Param("status") String status,@Param("circulationLogId") String circulationLogId);

    //void updateStatusByInpatNum(@Param("inpatNum")String inpatNum,@Param("modelType") String modelType);
    void updateStatusByInpatNum(@Param("circulationLogId")String circulationLogId,@Param("operator") String operator);

    CirculationLogEntity getPatientInfoByModeTypes(@Param("inpatNum")String inpatNum,@Param("modelTypes") String[] modelTypes);

    List<String> getTransport(@Param("transportId") String transportId);

    List<Map<String,String>> getOptions(@Param("dataId")String dataId);

    List<CirculationLogEntity> selectInHospLogByInpatNum(@Param("inpatNum")String inpatNum);

    CirculationLogEntity selectNewLogByInpatNumAndType(@Param("inpatNum")String inpatNum,@Param("type")String type,@Param("orgId")String orgId,@Param("modelType") String modelType);

    Map<String, String> queryDischargeDiagnosisByInpatNum(@Param("inpatNum")String inpatNum);

    List<Map<String, String>> queryNurseListByWardDeptId(@Param("wardDeptId")String wardDeptId,@Param("id") String id,@Param("keyWords") String keyWords);

    String queryOperationTime(@Param("inpatorderdataId")String inpatorderdataId);

    CirculationLogEntity queryCirculationLogById(@Param("circulationLogId")String circulationLogId);

    CirculationLogEntity queryCirculationLogByParams(@Param("inpatNum") String inpatNum,@Param("type") String type,@Param("inpatorderdataId") String inpatorderdataId,@Param("serialNo") Integer serialNo);

    CirculationLogEntity queryCirculationLogTransferOut(@Param("inpatNum") String inpatNum,@Param("inpatorderdataId") String inpatorderdataId);

    CirculationLogDTO queryDtoCirculationLogById(@Param("circulationLogId")String circulationLogId);

    Map<String,String> queryPatientCirculationLogById(@Param("circulationLogId")String circulationLogId);

    Map<String,String> queryPatientOperationByInpatorderdataId(@Param("inpatorderdataId")String inpatorderdataId);

    /**
     * 获取在文书修改的后的诊断号
     * @param inpatNum
     * @return
     */
    String queryDiagIdByInpatNum(@org.apache.ibatis.annotations.Param("inpatNum") String inpatNum);

    /**
     * 根据诊断编号获取诊断名称
     * @param diagId
     * @return
     */
    String queryDiagByDiagId(@org.apache.ibatis.annotations.Param("diagId") String diagId);
    /**
     * 根据诊断编号获取诊断名称
     * @param diagId
     * @return
     */
    Map<String,String> queryDiagInfoByDiagId(@org.apache.ibatis.annotations.Param("diagId") String diagId);
    /**
     * 根据诊断名称获取诊断编号
     * @param diagId
     * @return
     */
    String queryDiagByDiagName(@org.apache.ibatis.annotations.Param("diagName") String diagName);

    /**
     * 获取出院主诊断
     * @param inpatNum
     * @return
     */
    String queryOutHospitalDiag(@org.apache.ibatis.annotations.Param("inpatNum") String inpatNum);

    /**
     * 获取门诊诊断
     * @param inpatNum
     * @return
     */
    String queryOutpatientDiag(@org.apache.ibatis.annotations.Param("inpatNum") String inpatNum);
    String queryOutpatientDiag2(@org.apache.ibatis.annotations.Param("inpatNum") String inpatNum);
    Map<String,String> queryOutpatientDiag3(@org.apache.ibatis.annotations.Param("inpatNum") String inpatNum,@Param("flag") String flag);


    List<CirculationLogsDTO> queryCirculationLogList(@Param("inpatNums") List<String> inpatNums, @Param("types") List<String> types, @Param("startDate") String startDate, @Param("endDate") String endDate);

    /**
     * 更新床号
     */
    int updateBedNoStatus(@Param("bedNo")String bedNo,@Param("wardDeptId") String wardDeptId,@Param("status") String status);


    /**
     * 更新护士信息
     */
    Integer mergesaveMedicalRecordsOthers(@Param("othersId")String othersId,@Param("hospitalId")String hospitalId,
                                          @Param("inpatNum")String inpatNum,@Param("primaryNurseSign")String primaryNurseSign);


    /**
     * 根据住院号获取EMR_FILE_ID
     */
    List<CommonTaskCirculationDTO> queryCommonTaskCirculationByInpatNum(@Param("inpatNum")String inpatNum);


    List<CommonTaskCirculationDTO> queryEvaluationTime(@Param("inpatNum")String inpatNum,@Param("startDate")String startDate,@Param("endDate")String endDate);



    List<NurseFormDTO> getFromByCatalogId(@Param("id") String id);

    EmrFileIndexEntity findVteFileIndex(@Param("inpatNum") String inpatNum, @Param("catalogId") String catalogId);
    List<EmrFileIndexEntity> findVteFileIndex2(@Param("inpatNum") String inpatNum, @Param("catalogId") String catalogId);

    /**
     * 查询vte模板明细
     * @param catalogId
     * @return
     */
    List<EmrTemplateDetailEntity> getVteTemplateDetail(@Param("param")String param, @Param("catalogId")String catalogId);

    /**
     * 获取vte节点明细
     * @param emrFileId
     *
     * @return
     */
    List<Map<String, String>> getVteDetail(@Param("emrFileId")String emrFileId, @Param("tplDetails") List<EmrTemplateDetailEntity> tplDetails);

    EmrTemplateDTO listTemplateDto (@Param("ctlId") String ctlId);


    List<CirculationTemplateDTO> queryCirculationTemplateByModelRelation(@Param("status") String status);

    CirculationTemplateDTO queryCirculationTemplateByParentModelAndTplId(@Param("parentModel") String parentModel,@Param("tplId") String tplId);

    int insertCirculationTemplate(CirculationTemplateDTO circulationTemplateDTO);

    String queryPatientInHospitalByInpatNum(@Param("inpatNum") String inpatNum);

    Map<String,String> queryDeptByCode(@Param("deptCode") String deptCode);

    Map<String,String> queryDeptByInpatNum(@Param("inpatNum") String inpatNum);

    void updateLogById(@Param("logId") String logId,@Param("operator") String operator,@Param("nurseId") String nurseId,@Param("doctorId") String doctorId);

    List<Map<String,String>> queryWaitNewHospitalList(@Param("wardId") String wardId,@Param("keyWords") String keyWords);

    int updateDiagByInpatNum(@Param("inpatNum") String inpatNum,@Param("diagId") String diagId);

    PatientInHospitalDTO queryPatientInfoByWardIdAndBedNo(@Param("wardId") String wardId, @Param("bedNo") String bedNo,@Param("babyFlag") String babyFlag);
    PatientInHospitalDTO queryFinishOutHospPatientInfoByInpatNum(@Param("wardId") String wardId,@Param("inpatNum") String inpatNum,@Param("healthNum") String healthNum);
    PatientInHospitalDTO queryFinishOutDeptPatientInfoByInpatNum(@Param("wardId") String wardId,@Param("inpatNum") String inpatNum,@Param("healthNum") String healthNum);
    PatientInHospitalDTO queryFinishInDeptPatientInfoByInpatNum(@Param("wardId") String wardId,@Param("inpatNum") String inpatNum,@Param("healthNum") String healthNum);
    PatientInHospitalDTO queryFinishInDeptPatientInfoByInpatNum2(@Param("wardId") String wardId, @Param("bedNo") String bedNo,@Param("babyFlag") String babyFlag);


    List<Map<String,String>> queryBedNoByWardDeptId(@Param("wardId") String wardId,@Param("id") String id,@Param("keyWords") String keyWords,
                                                    @Param("babyFlag") String babyFlag,@Param("inpatNumList") List<String> inpatNumList,
                                                    @Param("bedNo") String bedNo);

    Map<String,String> querySysPrimaryDataValueById(@Param("dataValueId") String dataValueId);
    Map<String,String> queryHisDictCodeById(@Param("dataValueId") String dataValueId);
    int cancelUpdateInHospPatient(@Param("inpatNum") String inpatNum);
    int cancelUpdateInHospNurse(@Param("inpatNum") String inpatNum);

    List<Map<String,String>> queryWaitOutHospitalList(@Param("wardId") String wardId,@Param("keyWords") String keyWords,@Param("id") String id,
                                                      @Param("type") String type,@Param("bedNo") String bedNo);
    List<Map<String,String>> queryWaitInDeptList(@Param("wardId") String wardId,@Param("keyWords") String keyWords,
                                                 @Param("inpatNum") String inpatNum,@Param("healthNum") String healthNum);

    List<Map<String,String>> queryObstetricWard(@Param("wardId") String wardId, @Param("varCode") String varCode);

    String queryPatientOrdersByInpatNum(@Param("inpatNum") String inpatNum);

    int insertTmpCirculationLog(@Param("primaryId") String primaryId,@Param("circulationLogId") String circulationLogId);

    String queryBedLabel(@Param("wardDeptId") String wardDeptId,@Param("bedNo") String bedNo);

}



